Repository navigation
Conversation
kasimte
force-pushed
the
challenge-23-vec-part1
branch
from
October 7, 2026 04:42
39371b5 to
3fb3dc0
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Towards Challenge 23: Verify the safety of
Vecfunctions part 1 (issue #284).Kani harnesses for all 36 listed public
Vecfunctions inalloc::vec::mod.rs. Each runs the function's real body, with nocfg(kani)substitution and noassume(false). All 53 harnesses invec::verifypass viascripts/run-kani.sh(52 new, plus the pre-existingverify_swap_remove).Verification
push,push_within_capacity,spare_capacity_mut,split_at_spare_mut,into_boxed_slice,into_raw_parts_with_alloc,append_elements,extend_trusted,extend_desugaredwith_capacity(cap),capfree in1..=isize::MAX/4). Reallocation runs at symbolic capacity, not a fixed buffer.from_raw_parts,from_parts,from_parts_in,set_lensafety::{requires,ensures}viaproof_for_contract. The proofs build valid parts, and pre-initializeset_len's spare region, rather than assuming them. Obligations not expressible as predicates are documented at each contract.insert,remove,truncate,retain,drain,extract_if, and the restkani::vec::any_vecidiom.insertandremoveassert the moved element's post-shift position.retain_mutloop_invariant+loop_modifieson its in-place loop.push_within_capacityresults,set_lengrowth, andswap_remove's out-of-bounds panic (#[kani::should_panic]).insert,remove,truncate,swap_remove,retain,drainalso run over aDroptype and#[repr(align(16))].Every
kani::assumeis paired with akani::coverconfirming it is satisfiable: 55 covers, 29 assumes.Scope
Two mandatory criteria are met only in part, both blocked by tool limits at this pin:
loop_modifiesregion overflows CBMC's write-set machinery, so loop- and shift-bearing harnesses run at the largest length CBMC completes:0..=64for most,0..=4or0..=2where a shift or in-place loop dominates. A few fix the insert/copy offset, with values still symbolic. Allocation capacity itself is unbounded. Loop contracts onextend_withanddedup_bywere non-convergent in CI, so those stay bounded.T(no monomorphization). A Kani harness is monomorphic, so this clause cannot be expressed in Kani, and is deferred to the committee. The harnesses span the element-type axes instead: size, zero-size (Vec<()>), over-alignment (#[repr(align(16))]), and drop glue. On the size axis,RawVec::min_non_zero_capchooses the initial capacity fromsize_of::<T>()(one of three arms:== 1,<= 1024,> 1024); new 64- and 1025-byte grow-from-empty harnesses reach the<= 1024and> 1024arms (each with a capacitykani::cover), which theu8harnesses (the== 1arm) did not.Changes
Additive (+938/−0). The only shipped-code change beyond Kani-inert attributes is in
lib.rs:proc_macro_hygienebecomes unconditional (mirroringcore), soretain_mut's#[safety::…]loop attribute is present in every build rather thancfg(kani)-only.The spec's
from_nonnullandfrom_nonnull_inarefrom_partsandfrom_parts_inin the current source.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.